//
//  YTStashForewarningDetailsTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/11/15.
//

#import "YTStashForewarningDetailsTableViewCell.h"
@interface YTStashForewarningDetailsTableViewCell ()
@property (nonatomic ,strong) UILabel * typemslab;
@property (nonatomic ,strong) UILabel * Limitlab;
@property (nonatomic ,strong) UILabel * stockNumber;
@property (nonatomic ,strong) UILabel * areaName;
@property (nonatomic ,strong) UILabel * addressName;
@property (nonatomic ,strong) UILabel * shelfNumber;
@property (nonatomic ,strong) UILabel * createTime;


@end
@implementation YTStashForewarningDetailsTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UIView * makeview = [UIView new];
    makeview.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.offset(0);
        make.top.offset(kwt(10));
    }];
    
    UILabel * temp = [DTKTool labelWithText:@"预警信息" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:temp];
    [temp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(16));
        make.left.offset(kwt(12));
        make.height.offset(kwt(17));
    }];
    
    UILabel * typemslab = [DTKTool labelWithText:@"库存下限" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    self.typemslab = typemslab;
    [makeview addSubview:typemslab];
    [typemslab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(48));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * Limitlab = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#FE5402")];
    [makeview addSubview:Limitlab];
    self.Limitlab = Limitlab;
    [Limitlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(typemslab);
        make.left.offset(kwt(107));
        make.width.offset(kwt(256));
        make.height.offset(kwt(16));
    }];
    
    
    UILabel * templab1 = [DTKTool labelWithText:@"预警库存数" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeview addSubview:templab1];
    [templab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(Limitlab.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * stockNumber = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:stockNumber];
    self.stockNumber = stockNumber;
    [stockNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(templab1);
        make.left.offset(kwt(107));
        make.width.offset(kwt(256));
        make.height.offset(kwt(16));
    }];
    
    UILabel * templab2 = [DTKTool labelWithText:@"仓库区域" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeview addSubview:templab2];
    [templab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(stockNumber.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * areaName = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:areaName];
    self.areaName = areaName;
    [areaName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(templab2);
        make.left.offset(kwt(107));
        make.width.offset(kwt(256));
    }];
    UILabel * templab3 = [DTKTool labelWithText:@"存放位置" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeview addSubview:templab3];
    [templab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(areaName.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * addressName = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:addressName];
    self.addressName = addressName;
    addressName.numberOfLines = 0;
    [addressName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(templab3);
        make.left.offset(kwt(107));
        make.width.offset(kwt(256));
    }];
    UILabel * templab4 = [DTKTool labelWithText:@"货架编号" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeview addSubview:templab4];
    [templab4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(addressName.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * shelfNumber = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:shelfNumber];
    self.shelfNumber = shelfNumber;
    [shelfNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(templab4);
        make.left.offset(kwt(107));
        make.width.offset(kwt(256));
    }];
    UILabel * templab5 = [DTKTool labelWithText:@"预警时间" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeview addSubview:templab5];
    [templab5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(shelfNumber.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * createTime = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:createTime];
    self.createTime = createTime;
    [createTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(templab5 );
        make.left.offset(kwt(107));
        make.width.offset(kwt(256));
    }];
}

- (void)setModel:(YTStashForewarningModel *)model{
    _model = model;
    if(model.type == 1){//库存不足
        self.typemslab.text = @"库存下限";
        self.Limitlab.text = [NSString stringWithFormat:@"%lu%@",model.limitNumber,model.normsName];
    } else if(model.type == 2){//超出库存
        self.typemslab.text = @"库存上限";
        self.Limitlab.text = [NSString stringWithFormat:@"%lu%@",model.limitNumber,model.normsName];
    }
    
    self.stockNumber.text = [NSString stringWithFormat:@"%lu%@",model.stockNumber,model.normsName];
    self.areaName.text = model.areaName;
    [self.areaName mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset(model.areaNameH);
    }];
    self.addressName.text = model.addressName;
    [self.addressName mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset(model.addressNameH);
    }];
    self.shelfNumber.text = model.shelfNumber;
    [self.shelfNumber mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset(model.shelfNumberH);
    }];
    self.createTime.text = model.createTime;
}

@end
